﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using System;
using System.Collections.Generic;
using System.Text;
using Utility.Extensions;
namespace Shared.Contracts
{
    /// <summary>
    /// 带认证的 控制器 基类
    /// 默认请求地址 http://服务器地址/api/[Area]/[controller]/[action]
    /// 需要模块设置[Area("xxxx")]属性
    /// </summary>
    [Authorize]    
    [ApiController]
    [Route("api/[Area]/[controller]/[action]")]
    public class AuthorizeControllerBase : ControllerBase
    {
        /// <summary>
        /// 重载的 OkObjectResult
        /// 返回数据内容格式: { code:20000 , data = dynamic }
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public override OkObjectResult Ok([ActionResultObjectValue] object value)
        {
            return base.Ok(value.ToApiResult());
        }
    }
}
